home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / RKMLibsPrgs / graphics_libraries / primitives / genlockdemo.c < prev    next >
C/C++ Source or Header  |  1992-09-03  |  37KB  |  491 lines

  1. ;/* genlockdemo.c - Genlock VideoControl example.
  2. LC -b1 -cfist -v -j73 genlockdemo.c
  3. Blink FROM LIB:c.o,genlockdemo.o TO genlockdemo LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5.  
  6.  
  7. Copyright (c) 1992 Commodore-Amiga, Inc.
  8.  
  9. This example is provided in electronic form by Commodore-Amiga, Inc. for
  10. use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  11. published by Addison-Wesley (ISBN 0-201-56774-1).
  12.  
  13. The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  14. information on the correct usage of the techniques and operating system
  15. functions presented in these examples.  The source and executable code
  16. of these examples may only be distributed in free electronic form, via
  17. bulletin board or as part of a fully non-commercial and freely
  18. redistributable diskette.  Both the source and executable code (including
  19. comments) must be included, without modification, in any copy.  This
  20. example may not be published in printed form or distributed with any
  21. commercial product.  However, the programming techniques and support
  22. routines set forth in these examples may be used in the development
  23. of original executable software products for Commodore Amiga computers.
  24.  
  25. All other rights reserved.
  26.  
  27. This example is provided "as-is" and is subject to change; no
  28. warranties are made.  All use is at your own risk. No liability or
  29. responsibility is assumed.
  30.  
  31. */
  32.  
  33.  
  34. #include <exec/types.h>
  35. #include <exec/memory.h>
  36. #include <graphics/gfx.h>
  37. #include <graphics/gfxbase.h>
  38. #include <graphics/displayinfo.h>
  39. #include <graphics/VideoControl.h>
  40. #include <graphics/view.h>
  41. #include <intuition/intuition.h>
  42. #include <intuition/screens.h>
  43. #include <libraries/gadtools.h>
  44.  
  45. #include <clib/alib_stdio_protos.h>
  46. #include <clib/intuition_protos.h>
  47. #include <clib/graphics_protos.h>
  48. #include <clib/exec_protos.h>
  49. #include <clib/gadtools_protos.h>
  50.  
  51. #define INTUITIONNAME "intuition.library" /* intuitionbase.h does not define a library name. */
  52. #define GADTOOLSNAME "gadtools.library" /* gadtools.h does not define a library name. */
  53.  
  54. /* Some gadget ID's */
  55. #define BORDERBLANK_ID          16
  56. #define BORDERNOTRANS_ID        17
  57. #define BITPLANEKEY_ID          18
  58. #define CHROMAPLANE_ID          19
  59. #define CHROMAKEY_ID            20
  60.  
  61. /* Some protos */
  62. VOID main(int argc, char **argv);
  63. BOOL CheckPAL(STRPTR);
  64. UWORD strlen(STRPTR);
  65.  
  66. struct IntuitionBase *IntuitionBase;
  67. struct GfxBase *GfxBase;
  68. struct Library *GadToolsBase;
  69.  
  70.  
  71. /* Give me 3D look window (I'll use a quiet screen */
  72. static UWORD dri_Pens[] =
  73. {
  74.         0, 1, 1, 2, 1, 3, 1, 0, 3, ~0};
  75.  
  76. /* Just a demo, set everything to topaz 80. */
  77. static struct TextAttr Topaz80 = {
  78.         "topaz.font", 8, 0, 0,};
  79.  
  80. /* strings for cycle gadget */
  81. static STRPTR ChPlaneText[] = {
  82.         "Plane 0", "Plane 1", "Plane 2", "Plane 3", NULL};
  83.  
  84. struct EasyStruct failedES = {
  85.         sizeof(struct EasyStruct), 0, "GenlockDemo", "%s", "Continue",};
  86.  
  87. VOID main(int argc, char **argv)
  88. {
  89.         struct Screen *genscreen;
  90.         struct Window *controlwindow;
  91.         struct Gadget *glist, *gadget, *hitgadget;
  92.         struct ViewPort *vp;
  93.         struct View *viewlord;
  94.         void *vi;
  95.         struct NewGadget ng;
  96.         struct IntuiMessage *imsg;
  97.         struct TagItem vtags[24];
  98.         ULONG GadgetPtrs[21];
  99.         ULONG iclass, icode;
  100.         STRPTR gtextbuffer, gtextptr;
  101.         UWORD i, j;
  102.         BOOL ABORT = FALSE;
  103.         BOOL IsPAL;
  104.  
  105.         /* Fails silently if < V37 */
  106.         if (IntuitionBase = OpenLibrary(INTUITIONNAME, 37L)) 
  107.         {
  108.                 if (GfxBase = (struct GfxBase *) OpenLibrary(GRAPHICSNAME, 37L)) 
  109.                 {
  110.                         if (GadToolsBase = OpenLibrary(GADTOOLSNAME, 37L)) 
  111.                         {
  112.                                 if (GfxBase->ChipRevBits0 & GFXF_HR_DENISE) 
  113.                                 {
  114.                                         /* Check if the user happens to prefer PAL or if this is a true PAL System. */
  115.                                         IsPAL = CheckPAL("Workbench");
  116.                                         /* buffer for some gadget text */
  117.                                         if (gtextbuffer = AllocMem(256, MEMF_CLEAR)) 
  118.                                         {
  119.                                                 gtextptr = gtextbuffer;
  120.  
  121.                                                 /* Open a 'standard' HIRES screen */
  122.                                                 if (genscreen = OpenScreenTags(NULL, SA_Pens, (ULONG) dri_Pens,
  123.                                                 SA_DisplayID, HIRES_KEY,
  124.                                                 SA_Depth, 4,
  125.                                                 /* Give me a lot of border */
  126.                                                 SA_Width, 640,
  127.                                                 SA_Height, (IsPAL) ? 256 : 200,
  128.                                                 SA_Overscan, 0,
  129.                                                 /* Hold the titlebar, please */
  130.                                                 SA_Quiet, TRUE,
  131.                                                 /* Give me sysfont 0 as default rastport font. */
  132.                                                 SA_SysFont, 1,
  133.                                                 TAG_DONE)) 
  134.                                                 {
  135.  
  136.                                                         /* Blast some colorbars in screen's rastport, leave some color 0 gaps */
  137.                                                         for (i = 0, j = 0; i < 16; i++, j += 40) 
  138.                                                         {
  139.                                                                 SetAPen(&(genscreen->RastPort), i);
  140.                                                                 RectFill(&(genscreen->RastPort), (j + 1), 0, (j + 30), (IsPAL) ? 255 : 199);
  141.  
  142.                                                         }
  143.                                                         /* A line to show where borders start */
  144.                                                         SetAPen(&(genscreen->RastPort), 5);
  145.                                                         Move(&(genscreen->RastPort),0,0);
  146.                                                         Draw(&(genscreen->RastPort),genscreen->Width-1,0);
  147.                                                         Draw(&(genscreen->RastPort),genscreen->Width-1,genscreen->Height-1);
  148.                                                         Draw(&(genscreen->RastPort),0,genscreen->Height-1);
  149.                                                         Draw(&(genscreen->RastPort),0,0);
  150.  
  151.                                                         /* Open a restricted window, no draggin, sizing, just closing.
  152.                                                                                                          * (don't want to refresh screen)
  153.                                                                                                          */
  154.                                                         if (controlwindow = OpenWindowTags(NULL, WA_Title, (ULONG) "VideoControl",
  155.                                                         WA_Left, 210,
  156.                                                         WA_Top, 20,
  157.                                                         WA_Width, 220,
  158.                                                         WA_Height, 150,
  159.                                                         WA_CustomScreen, genscreen,
  160.                                                         WA_Flags, WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_NOCAREREFRESH,
  161.                                                         WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP,
  162.                                                         TAG_DONE)) {
  163.  
  164.                                                                 /* Ok, got a window, lets make some gadgets */
  165.                                                                 if (vi = GetVisualInfo(genscreen, TAG_END)) 
  166.                                                                 {
  167.                                                                         if (gadget = CreateContext(&glist)) 
  168.                                                                         {
  169.                                                                                 ng.ng_TextAttr = &Topaz80;
  170.                                                                                 ng.ng_VisualInfo = vi;
  171.                                                                                 ng.ng_Flags = PLACETEXT_LEFT | NG_HIGHLABEL;
  172.  
  173.                                                                                 ng.ng_LeftEdge = controlwindow->BorderLeft + 120;
  174.                                                                                 ng.ng_TopEdge = controlwindow->BorderTop + 2;
  175.                                                                                 ng.ng_Width = 12;
  176.                                                                                 ng.ng_Height = 12;
  177.                                                                                 ng.ng_GadgetText = "BORDERBLANK";
  178.                                                                                 ng.ng_GadgetID = BORDERBLANK_ID;
  179.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  180.                                                                                 GadgetPtrs[BORDERBLANK_ID] = (ULONG) gadget;
  181.  
  182.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  183.                                                                                 ng.ng_GadgetText = "BORDERNOTRANS";
  184.                                                                                 ng.ng_GadgetID = BORDERNOTRANS_ID;
  185.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  186.                                                                                 GadgetPtrs[BORDERNOTRANS_ID] = (ULONG) gadget;
  187.  
  188.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  189.                                                                                 ng.ng_GadgetText = "CHROMAKEY";
  190.                                                                                 ng.ng_GadgetID = CHROMAKEY_ID;
  191.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  192.                                                                                 GadgetPtrs[CHROMAKEY_ID] = (ULONG) gadget;
  193.  
  194.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  195.                                                                                 ng.ng_GadgetText = "BITPLANEKEY";
  196.                                                                                 ng.ng_GadgetID = BITPLANEKEY_ID;
  197.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  198.                                                                                 GadgetPtrs[BITPLANEKEY_ID] = (ULONG) gadget;
  199.  
  200.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  201.                                                                                 ng.ng_Width = 90;
  202.                                                                                 ng.ng_GadgetText = "CHROMAPLANE";
  203.                                                                                 ng.ng_GadgetID = CHROMAPLANE_ID;
  204.                                                                                 gadget = CreateGadget(CYCLE_KIND, gadget, &ng, GTCY_Labels, (ULONG) ChPlaneText, TAG_END);
  205.                                                                                 GadgetPtrs[CHROMAPLANE_ID] = (ULONG) gadget;
  206.  
  207.                                                                                 ng.ng_TopEdge += gadget->Height + 20;
  208.                                                                                 ng.ng_Width = 12;
  209.                                                                                 ng.ng_Flags = PLACETEXT_ABOVE | NG_HIGHLABEL;
  210.                                                                                 for (j = 0; j < 2; j++) 
  211.                                                                                 {
  212.                                                                                         for (i = 0; i < 8; i++) 
  213.                                                                                         {
  214.                                                                                                 ng.ng_LeftEdge = controlwindow->BorderLeft + 2 + (i * gadget->Width);
  215.                                                                                                 sprintf(gtextptr, "%ld", i + (j * 8));
  216.                                                                                                 ng.ng_GadgetText = gtextptr;
  217.                                                                                                 ng.ng_GadgetID = i + (j * 8);
  218.                                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  219.                                                                                                 GadgetPtrs[i] = (ULONG) gadget;
  220.                                                                                                 gtextptr += strlen(gtextptr) + 1;
  221.                                                                                         }
  222.                                                                                         ng.ng_TopEdge += gadget->Height;
  223.                                                                                         ng.ng_Flags = PLACETEXT_BELOW | NG_HIGHLABEL;
  224.                                                                                 }
  225.                                                                                 AddGList(controlwindow, glist, -1, -1, NULL);
  226.                                                                                 RefreshGList(glist, controlwindow, NULL, -1);
  227.                                                                                 GT_RefreshWindow(controlwindow, NULL);
  228.  
  229.                                                                                 /* Finally, a window with some gadgets...
  230.                                                                                  *
  231.                                                                                  * Get the current genlock state.
  232.                                                                                  * Obviously I already know what the settings will be (all off),
  233.                                                                                  * since I opened the screen myself. Do it just to show how to get them.
  234.                                                                                  */
  235.  
  236.                                                                                 vp = &(genscreen->ViewPort);
  237.  
  238.                                                                                 /* Is borderblanking on? */
  239.                                                                                 vtags[0].ti_Tag = VTAG_BORDERBLANK_GET;
  240.                                                                                 vtags[0].ti_Data = NULL;
  241.                                                                                 /* Is bordertransparent set */
  242.                                                                                 vtags[1].ti_Tag = VTAG_BORDERNOTRANS_GET;
  243.                                                                                 vtags[1].ti_Data = NULL;
  244.                                                                                 /* Key on bitplane? */
  245.                                                                                 vtags[2].ti_Tag = VTAG_BITPLANEKEY_GET;
  246.                                                                                 vtags[2].ti_Tag = NULL;
  247.                                                                                 /* Get plane which is used to key on */
  248.                                                                                 vtags[3].ti_Tag = VTAG_CHROMA_PLANE_GET;
  249.                                                                                 vtags[3].ti_Data = NULL;
  250.                                                                                 /* Chromakey overlay on? */
  251.                                                                                 vtags[4].ti_Tag = VTAG_CHROMAKEY_GET;
  252.                                                                                 vtags[4].ti_Data = NULL;
  253.  
  254.                                                                                 for (i = 0; i < 16; i++) 
  255.                                                                                 {
  256.                                                                                         /* Find out which colors overlay */
  257.                                                                                         vtags[i + 5].ti_Tag = VTAG_CHROMA_PEN_GET;
  258.                                                                                         vtags[i + 5].ti_Data = i;
  259.                                                                                 }
  260.  
  261.                                                                                 /* Indicate end of tag array */
  262.                                                                                 vtags[21].ti_Tag = VTAG_END_CM;
  263.                                                                                 vtags[21].ti_Data = NULL;
  264.  
  265.                                                                                 /* And send the commands. On return the Tags themself will
  266.                                                                                                                                                          * indicate the genlock settings for this ViewPort's ColorMap.
  267.                                                                                                                                                          */
  268.                                                                                 VideoControl(vp->ColorMap, vtags);
  269.  
  270.                                                                                 /* And initialize gadgets, according to genlock settings */
  271.                                                                                 if (vtags[0].ti_Tag == VTAG_BORDERBLANK_SET)
  272.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BORDERBLANK_ID], controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  273.                                                                                 if (vtags[1].ti_Tag == VTAG_BORDERNOTRANS_SET)
  274.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BORDERNOTRANS_ID], controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  275.                                                                                 if (vtags[2].ti_Tag == VTAG_BITPLANEKEY_SET)
  276.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BITPLANEKEY_ID], controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  277.                                                                                 if (vtags[3].ti_Tag == VTAG_CHROMA_PLANE_SET)
  278.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[CHROMAPLANE_ID], controlwindow, NULL, GTCY_Active, vtags[3].ti_Data, TAG_DONE);
  279.                                                                                 if (vtags[4].ti_Tag == VTAG_CHROMAKEY_SET)
  280.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[CHROMAKEY_ID], controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  281.                                                                                 for (i = 0; i < 16; i++) 
  282.                                                                                 {
  283.                                                                                         if (vtags[i + 5].ti_Tag == VTAG_CHROMA_PEN_SET)
  284.                                                                                                 GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[i], controlwindow, NULL, GTCB_Checked, TRUE);
  285.                                                                                 }
  286.  
  287.                                                                                 /* Will only send single commands from here on. */
  288.                                                                                 vtags[1].ti_Tag = VTAG_END_CM;
  289.  
  290.                                                                                 /* Get user input. */
  291.                                                                                 do 
  292.                                                                                 {
  293.                                                                                         WaitPort(controlwindow->UserPort);
  294.                                                                                         while (imsg = GT_GetIMsg(controlwindow->UserPort)) {
  295.                                                                                                 iclass = imsg->Class;
  296.                                                                                                 icode = imsg->Code;
  297.                                                                                                 hitgadget = (struct Gadget *) imsg->IAddress;
  298.                                                                                                 GT_ReplyIMsg(imsg);
  299.  
  300.                                                                                                 switch (iclass) 
  301.                                                                                                 {
  302.                                                                                                 case GADGETUP:
  303.                                                                                                         if (hitgadget->GadgetID < 16) 
  304.                                                                                                         {
  305.                                                                                                                 /* Set colorkey */
  306.                                                                                                                 if (hitgadget->Flags & SELECTED)
  307.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PEN_SET;
  308.                                                                                                                 /* Clear colorkey */
  309.                                                                                                                 else
  310.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PEN_CLR;
  311.                                                                                                                 vtags[0].ti_Data = hitgadget->GadgetID;
  312.                                                                                                         } 
  313.                                                                                                         else 
  314.                                                                                                         {
  315.                                                                                                                 switch (hitgadget->GadgetID) {
  316.                                                                                                                 case BORDERBLANK_ID:
  317.                                                                                                                         /* Set borderblanking on */
  318.                                                                                                                         if (hitgadget->Flags & SELECTED)
  319.                                                                                                                                 vtags[0].ti_Tag = VTAG_BORDERBLANK_SET;
  320.                                                                                                                         /* Turn borderblanking off */
  321.                                                                                                                         else
  322.                                                                                                                                 vtags[0].ti_Tag = VTAG_BORDERBLANK_CLR;
  323.                                                                                                                         break;
  324.                                                                                                                 case BORDERNOTRANS_ID:
  325.                                                                                                                         /* Set bordertransparency on */
  326.                                                                                                                         if (hitgadget->Flags & SELECTED)
  327.                                                                                                                                 vtags[0].ti_Tag = VTAG_BORDERNOTRANS_SET;
  328.                                                                                                                         /* Turn bordertransparency off */
  329.                                                                                                                         else
  330.                                                                                                                                 vtags[0].ti_Tag = VTAG_BORDERNOTRANS_CLR;
  331.                                                                                                                         break;
  332.                                                                                                                 case BITPLANEKEY_ID:
  333.                                                                                                                         /* Key on current selected bitplane (chromaplane) */
  334.                                                                                                                         if (hitgadget->Flags & SELECTED)
  335.                                                                                                                                 vtags[0].ti_Tag = VTAG_BITPLANEKEY_SET;
  336.                                                                                                                         /* Turn bitplane keying off */
  337.                                                                                                                         else
  338.                                                                                                                                 vtags[0].ti_Tag = VTAG_BITPLANEKEY_CLR;
  339.                                                                                                                         break;
  340.                                                                                                                 case CHROMAPLANE_ID:
  341.                                                                                                                         /* Set plane to key on */
  342.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PLANE_SET;
  343.                                                                                                                         vtags[0].ti_Data = icode;
  344.                                                                                                                         break;
  345.                                                                                                                 case CHROMAKEY_ID:
  346.                                                                                                                         /* Set chromakey overlay on */
  347.                                                                                                                         if (hitgadget->Flags & SELECTED)
  348.                                                                                                                                 vtags[0].ti_Tag = VTAG_CHROMAKEY_SET;
  349.                                                                                                                         /* Turn chromakey overlay off */
  350.                                                                                                                         else
  351.                                                                                                                                 vtags[0].ti_Tag = VTAG_CHROMAKEY_CLR;
  352.                                                                                                                         break;
  353.                                                                                                                 }
  354.                                                                                                         }
  355.  
  356.                                                                                                         /* send video command */
  357.                                                                                                         VideoControl(vp->ColorMap, vtags);
  358.                                                                                                         /* Get the View for this genlock screen. */
  359.                                                                                                         viewlord = ViewAddress();
  360.                                                                                                         /* And remake the viewport */
  361.                                                                                                         MakeVPort(viewlord, vp);
  362.                                                                                                         MrgCop(viewlord);
  363.                                                                                                         LoadView(viewlord);
  364.                                                                                                         break;
  365.  
  366.                                                                                                 case CLOSEWINDOW:
  367.                                                                                                         /* Get out of here */
  368.                                                                                                         ABORT = TRUE;
  369.                                                                                                         break;
  370.                                                                                                 }
  371.                                                                                         }
  372.                                                                                 } 
  373.                                                                                 while (ABORT == FALSE);
  374.  
  375.                                                                                 RemoveGList(controlwindow, glist, -1);
  376.                                                                                 FreeGadgets(glist);
  377.                                                                         } 
  378.                                                                         else
  379.                                                                                 EasyRequest(NULL, &failedES, NULL, "Can't create gadget context");
  380.                                                                         FreeVisualInfo(vi);
  381.                                                                 } 
  382.                                                                 else
  383.                                                                         EasyRequest(NULL, &failedES, NULL, "Can't get visual info");
  384.                                                                 CloseWindow(controlwindow);
  385.                                                         } 
  386.                                                         else
  387.                                                                 EasyRequest(NULL, &failedES, NULL, "Can't open window");
  388.                                                         CloseScreen(genscreen);
  389.                                                 } 
  390.                                                 else
  391.                                                         EasyRequest(NULL, &failedES, NULL, "Can't open screen");
  392.                                                 FreeMem(gtextbuffer, 256);
  393.                                         } 
  394.                                         else
  395.                                                 EasyRequest(NULL, &failedES, NULL, "Out of memory");
  396.                                 } 
  397.                                 else
  398.                                         EasyRequest(NULL, &failedES, NULL, "Requires ECS");
  399.                                 CloseLibrary(GadToolsBase);
  400.                         }
  401.                         else
  402.                             if (argc)
  403.                                 printf("%s: Unable to open %s\n", argv[0], GADTOOLSNAME);
  404.                         CloseLibrary((struct Library *) GfxBase);
  405.                 }
  406.                 else
  407.                     if (argc)
  408.                         printf("%s: Unable to open %s\n", argv[0], GRAPHICSNAME);
  409.                 CloseLibrary(IntuitionBase);
  410.         }
  411.         else
  412.             if (argc)
  413.                 printf("%s: Unable to open %s\n", argv[0], INTUITIONNAME);
  414. }
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421. /* Generic routine to check for a PAL System.
  422.  * CheckPAL returns TRUE, if the the videomode of the specified public screen (or default videmode)
  423.  * is PAL.
  424.  * If the screenname is NULL, the default public screen will be used.
  425.  */
  426.  
  427.  
  428. BOOL CheckPAL(STRPTR screenname)
  429. {
  430.         struct Screen *screen;
  431.         ULONG modeID = LORES_KEY;
  432.         struct DisplayInfo displayinfo;
  433.         BOOL IsPAL;
  434.  
  435.         if (GfxBase->LibNode.lib_Version >= 36) 
  436.         {
  437.         /*
  438.          * We got V36, so lets use the new calls to find out what
  439.          * kind of videomode the user (hopefully) prefers.
  440.          */
  441.     
  442.             if (screen = LockPubScreen(screenname)) 
  443.             {
  444.                 /*
  445.                  * Use graphics.library/GetVPModeID() to get the ModeID of the specified screen.
  446.                  * Will use the default public screen (Workbench most of the time) if NULL It is
  447.                  * _very_ unlikely that this would be invalid, heck it's impossible.
  448.                  */
  449.                 if ((modeID = GetVPModeID(&(screen->ViewPort))) != INVALID_ID) 
  450.                 {
  451.                     /*
  452.                      * If the screen is in VGA mode, we can't tell whether the system is PAL or NTSC. So
  453.                      * to be fullproof we fall back to the displayinfo of the default.monitor by
  454.                      * inquiring about just the LORES_KEY displaymode if we don't know. The
  455.                      * default.monitor reflects the initial video setup of the system, thus is an alias
  456.                      * for either ntsc.monitor or pal.monitor. We only use the displaymode of the
  457.                      * specified public screen if it's display mode is PAL or NTSC and NOT the default.
  458.                      */
  459.  
  460.                     if (!((modeID & MONITOR_ID_MASK) == NTSC_MONITOR_ID ||
  461.                           (modeID & MONITOR_ID_MASK) == PAL_MONITOR_ID))
  462.                         modeID = LORES_KEY;
  463.                 }
  464.                 UnlockPubScreen(NULL, screen);
  465.             } /* if fails modeID = LORES_KEY. Can't lock screen, so fall back on default monitor. */
  466.     
  467.             if (GetDisplayInfoData(NULL, (UBYTE *) & displayinfo,
  468.                 sizeof(struct DisplayInfo), DTAG_DISP, modeID)) 
  469.             {
  470.                 if (displayinfo.PropertyFlags & DIPF_IS_PAL)
  471.                     IsPAL = TRUE;
  472.                 else
  473.                     IsPAL = FALSE;  /* Currently the default monitor is always either
  474.                                      * PAL or NTSC.
  475.                                      */
  476.             }
  477.         } 
  478.         else /* < V36. The enhancements to the videosystem in V36 cannot be better expressed than
  479.                 * with the simple way to determine PAL in V34.
  480.                 */
  481.             IsPAL= (GfxBase->DisplayFlags & PAL) ? TRUE : FALSE;
  482.     
  483.         return(IsPAL);
  484. }
  485.     
  486.  
  487.  
  488.  
  489.  
  490.  
  491.